const synth = window.speechSynthesis
/**
 * 文字转语音
 */
export default {
  /**
     * 语音提醒
     * @param {String} text
     */
  speek (text,lang) {
    const ssu = new SpeechSynthesisUtterance(text)
    if (lang) {
      SpeechSynthesisUtterance.lang = lang
    } else {
      SpeechSynthesisUtterance.lang = 'zh-CN'
    }
    synth.speak(ssu)
  },
  /**
   * 退出语音
   */
  cancel () {
    synth.cancel()
  }
}